﻿#ifndef BUSS_MENU_H
#define BUSS_MENU_H

#include <QWidget>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QVBoxLayout>
#include "database.h"

namespace Ui {
class Buss_menu;
}

class Buss_menu : public QWidget
{
    Q_OBJECT

public:
    explicit Buss_menu(int bus_id,QWidget *parent = nullptr);
    ~Buss_menu();
    void setBusId(int busId){
        this->bus_id = busId;
    }
    void getImg();
private slots:
    void on_pushButton_return_clicked();

    void on_pushButton_add_clicked();

    void on_pushButton_refresh_clicked();

    void on_pushButton_serach_clicked();
    
    void refreshMenuList(); // 移动到slots部分，使其可作为槽函数

private:
    QString m_currentEditImagePath; // 用于存储编辑时选择的图片路径
    Ui::Buss_menu *ui;
    QSqlDatabase db;
    QString finalImagePath;
    void setupDatabase();
    void refreshMenuList(const QString &searchText); // 新增重载方法，支持搜索文本参数
    void clearMenuList();
    void editMenuItem(int id, const QString &name, double price, const QString &description, const QString &imgPath);
    int bus_id;
};

#endif // BUSS_MENU_H
